<!-- php:$title = "修改邮箱_会员中心" --><!-- include tpl=header title=$title -->
<script type="text/javascript">
$(document).ready(function(){
	$("#userinfo_email").submit(function(){
		$(this).ajaxSubmit({
			'type':'post',
			'dataType':'json',
			'url':api_url('usercp','email'),
			'success':function(rs){
				if(rs.status){
					$.dialog.alert("您的邮箱更新成功",function(){
						$.phpok.reload();
					},'succeed');
				}else{
					$.dialog.alert(rs.info);
					return false;
				}
			}
		});
		return false;
	});
});
</script>
<!-- if $sendemail -->
<script type="text/javascript">
var maxtime = 60;
var email_send_lock = false;
var win_time_out;
function update_send_email_loading()
{
	maxtime--;
	if(maxtime < 1){
		$("#email_send_status").val('发送验证码');
		email_send_lock = false;
		maxtime = 60;
		window.clearInterval(win_time_out);
		return true;
	}
	var tips = "验证码已发送("+maxtime+")";
	$("#email_send_status").val(tips);
}

function send_email()
{
	if(email_send_lock){
		$.dialog.alert('验证码已发送，请一分钟后再执行');
		return false;
	}
	var url = api_url('vcode','email','act=register');
	var email = $("#email").val();
	if(!email){
		$.dialog.alert('邮箱不能为空');
		return false;
	}
	url += "&email="+email;
	$.dialog.tips("正在执行中，请稍候…");
	update_send_email_loading();
	$.phpok.json(url,function(rs){
		if(!rs.status){
			$.dialog.alert(rs.info);
			$("#email_send_status").val('发送验证码');
			return false;
		}
		maxtime = 60;
		email_send_lock = true;
		win_time_out = setInterval("update_send_email_loading()",1000);
	});
}
</script>
<!-- /if -->
<section class="container"><div class="mt-3"><!-- include tpl=block/breadcrumb --></div></section>
<section class="container">
	<div class="row">
		<div class="col-sm-3">
			<!-- include tpl=block/usercp_nav -->
		</div>
		<div class="col-sm-9">
			<div class="card">
				<div class="card-header">邮箱修改</div>
				<div class="card-body">
					<form method="post" id="userinfo_email">
					<div class="row form-group">
						<label for="pass" class="col-sm-2 text-right">会员密码</label>
						<div class="col-sm-10"><input type="password" name="pass" id="pass" /></div>
					</div>
					<!-- if $rs.email -->
					<div class="row form-group">
						<label for="oldemail" class="col-sm-2 text-right">原邮箱</label>
						<div class="col-sm-10"><input type="text" name="oldemail" id="oldemail" value="{$rs.email}" disabled /></div>
					</div>
					<!-- /if -->
					<div class="row form-group">
						<label for="email" class="col-sm-2 text-right">新邮箱</label>
						<div class="col-sm-{$sendemail ? 6 : 10}"><input type="text" name="email" id="email" /></div>
						<!-- if $sendemail -->
						<div class="col-sm-4"><input type="button" value="发送验证码" onclick="send_email()" class="btn btn-primary" id="email_send_status" /></div>
						<!-- /if -->
					</div>
					<!-- if $sendemail -->
					<div class="row form-group">
						<label for="chkcode" class="col-sm-2 text-right">验证码</label>
						<div class="col-sm-10"><input type="text" name="chkcode" id="chkcode" /></div>
					</div>
					<!-- /if -->
					<div class="row form-group">
						<label class="col-sm-2 text-right"></label>
						<div class="col-sm-10"><input type="submit" id="phpok_submit" value="提 交" class="btn btn-primary"></div>
					</div>
					</form>
				</div>
			</div>
			<div class="card mt-3">
				<div class="card-header">友情说明</div>
				<ul class="list-group list-group-flush">
					<li class="list-group-item">邮箱修改需要您提供会员密码认证</li>
					<li class="list-group-item">请确填写有效的邮箱，国内用户建议使用126邮箱或QQ邮箱</li>
				</ul>
			</div>
		</div>
	</div>
</section>

<!-- include tpl=footer -->